
 const int XMPP_STATE_MACHINE = 100001;
 const int FTP_STATE_MACHINE  = 100002;

 #ifdef __WXMSW__
  unsigned int __stdcall
 #else
  void *
 #endif
 session_thread(void *);
 
 ///////////////////////////////////////////////////
 /// Class NP
 ///////////////////////////////////////////////////

 class NP : public wxFrame, private wxLog
 {
   public:

     wxLog *old_logger;

     void  OnIdle (wxIdleEvent& e) { e.Skip(); }
     void  OnLeftUp (wxMouseEvent& WXUNUSED(e)) { if (HasCapture()) ReleaseMouse(); }
     void  OnSize (wxSizeEvent& e) { Refresh(); e.Skip(); }
     void  OnText (wxCommandEvent&);
     void  OnMenu (wxMouseEvent&);
     void  OnClose (wxCloseEvent&);
     void  OnPaint (wxPaintEvent&);
     void  OnMotion (wxMouseEvent&);
     void  OnLeftDown (wxMouseEvent&);
     void  OnLeftDClick (wxMouseEvent&); 
     void  OnEraseBackground (wxEraseEvent& WXUNUSED(e)) { }
     void  OnConnect (wxCommandEvent& WXUNUSED(e)) { state_connecting(); }
     void  session_connect (wxCommandEvent&);
     void  session_disconnect (wxCommandEvent&);
     void  remove_protocol_panel (void);
     void  xmpp_state_machine (wxCommandEvent&);
     void  ftp_state_machine (wxCommandEvent&);
     void  help_about (wxCommandEvent&);
     void  state_connecting(void);

     void  put_cfg(const char *, wxString, bool bDeleteLast = true);
     void  get_cfg(const char *, wxString *);

     TBIcon *m_taskBarIcon;

   #if defined(__WXOSX__) && wxOSX_USE_COCOA
     TBIcon   *m_dockIcon;
   #endif 

     wxSize          n_size;
     FILE          * fp;
     wxPoint         m_delta;
     wxPanel       * p2;
     QTab          * n_status;

     wxBoxSizer    * szTop;
     wxBoxSizer    * szTitle;
     wxBoxSizer    * szMinMax;
     wxBoxSizer    * szQC;

     QTab          * n_menu;
     QBitmap       * n_minus;
     QBitmap       * n_close;

     wxTextCtrl    * m_user;
     wxTextCtrl    * m_password;
     QTab          * n_chat_g;
     QTab          * n_chat_f;
     wxButton      * n_connect;
     TaskBarBaloon * baloon;

     NP(wxWindow* parent,
        wxWindowID id = wxID_ANY,
        const wxString& title = "Netpad", 
        const wxPoint& pos = wxDefaultPosition,
        const wxSize& size = wxDefaultSize, //wxSize(300, 300), 
        long style = wxCLIP_CHILDREN|wxNO_BORDER|wxFRAME_SHAPED|wxTAB_TRAVERSAL);

     ~NP();

     DECLARE_EVENT_TABLE()
 };

 class SessionThread : public wxThread
 {
   public:

    static wxFrame* m_parent;

    SessionThread(wxFrame* parent) { m_parent = parent; }
    
    virtual ExitCode Entry();
 };

 class QApp : public wxApp
 {
   public:

     NP *m_frame;

     virtual bool OnInit();
  
     /* ~QApp() { delete m_frame; } */
 
 };
 
 DECLARE_APP(QApp)

 void
  state_machine (connection *);

